import axios from 'axios'

const get = ({url, params={}}) => {
  return new Promise((resolve, reject) => {
    axios({
      url,
      method: 'GET',
      params
    })
    .then(result => {
      resolve(result)
    })
    .catch(error => {
      reject(error)
    })
  })
}

const post = ({url, data=''}) => {
  return new Promise((resolve, reject) => {
    axios({
      url,
      method: 'post',
      data,
      headers: {
        'content-type': 'application/x-www-form-urlencoded'
      }
    })
    .then(result => {
      resolve(result)
    })
    .catch(error => {
      reject(error)
    })
  })
}

export {
  get,
  post
}